//
//  AppDelegate.m
//  网易云音乐碎片
//
//  Created by dllo on 15/11/10.
//  Copyright © 2015年 蓝鸥科技. All rights reserved.
//

#import "AppDelegate.h"
#import "FindMusicViewController.h"
#import "MyMusicViewController.h"
#import "FriendViewController.h"
#import "IdViewController.h"

@interface AppDelegate ()<UITabBarControllerDelegate>

@end

@implementation AppDelegate

- (void)dealloc
{
    [_window release];
    [super dealloc];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
//// 发现音乐
//    FindMusicViewController *findMusicVC = [[FindMusicViewController alloc] init];
//    UINavigationController *findMusicNaVC = [[UINavigationController alloc] initWithRootViewController:findMusicVC];
//    UIImage *findImage1 = [UIImage imageNamed:@"cm2_btm_icn_discovery.png"];
//    findImage1 = [findImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage *findImage2 = [UIImage imageNamed:@"cm2_btm_icn_discovery_prs.png"];
//    findImage2 = [findImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    findMusicNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"发现音乐" image:findImage1 selectedImage:findImage2];
//    [findMusicNaVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"111.png"] forBarMetrics:UIBarMetricsDefault];
//// 我的音乐
//    MyMusicViewController *myMusicVC = [[MyMusicViewController alloc] init];
//    UINavigationController *myMusicNaVC = [[UINavigationController alloc] initWithRootViewController:myMusicVC];
//    UIImage *myImage1 = [UIImage imageNamed:@"cm2_btm_icn_music.png"];
//    myImage1 = [myImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage *myImage2 = [UIImage imageNamed:@"cm2_btm_icn_music_prs.png"];
//    myImage2 = [myImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    myMusicNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的音乐" image:myImage1 selectedImage:myImage2];
//    [myMusicNaVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"111.png"] forBarMetrics:UIBarMetricsDefault];
//// 朋友
//    FriendViewController *friendVC = [[FriendViewController alloc] init];
//    UINavigationController *friendNaVC = [[UINavigationController alloc] initWithRootViewController:friendVC];
//    UIImage *friendImage1 = [UIImage imageNamed:@"cm2_btm_icn_friend.png"];
//    friendImage1 = [friendImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage *friendImage2 = [UIImage imageNamed:@"cm2_btm_icn_friend_prs.png"];
//    friendImage2 = [friendImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    friendNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"朋友" image:friendImage1 selectedImage:friendImage2];
//    [friendNaVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"111.png"] forBarMetrics:UIBarMetricsDefault];
//// 账号
//    IdViewController *idVC = [[IdViewController alloc] init];
//    UINavigationController *idNaVC = [[UINavigationController alloc] initWithRootViewController:idVC];
//    UIImage *idImage1 = [UIImage imageNamed:@"cm2_btm_icn_account.png"];
//    idImage1 = [idImage1 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    UIImage *idImage2 = [UIImage imageNamed:@"cm2_btm_icn_account_prs.png"];
//    idImage2 = [idImage2 imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
//    idNaVC.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"账号" image:idImage1 selectedImage:idImage2];
//    [idNaVC.navigationBar setBackgroundImage:[UIImage imageNamed:@"111.png"] forBarMetrics:UIBarMetricsDefault];
//    
//// 字体颜色 选中
//     [[UITabBarItem appearance] setTitleTextAttributes:@{NSFontAttributeName : [UIFont fontWithName:@"HelveticaNeue-Bold" size:12.0F], NSForegroundColorAttributeName : [UIColor whiteColor]} forState:UIControlStateSelected];
//    
//    UITabBarController *tabBarC = [[UITabBarController alloc] init];
//    tabBarC.viewControllers = [NSArray arrayWithObjects:findMusicNaVC, myMusicNaVC, friendNaVC, idNaVC, nil];
//// 设置tabBar的整体颜色
//    tabBarC.tabBar.barTintColor = [UIColor colorWithWhite:0.298 alpha:1.000];
//// 设置选中按钮的背景颜色
//    tabBarC.tabBar.tintColor = [UIColor redColor];
//// 设置是否显示半透明效果
//    tabBarC.tabBar.translucent = YES;
//    tabBarC.delegate = self;
//    self.window.rootViewController = tabBarC;
    
    
    self.tabBarVC = [[TabBarViewController alloc] initWithNibName:@"tabbarViewController" bundle:nil];
    self.window.rootViewController = self.tabBarVC;
    
    
    
//    [findMusicVC release];
//    [findMusicNaVC release];
//    [myMusicVC release];
//    [myMusicNaVC release];
//    [friendNaVC release];
//    [friendVC release];
//    [idNaVC release];
//    [idVC release];
    [_window release];
    
    
    
    
    
    
    return YES;
}

// 点击按钮后触发的方法
-(void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
    
    // 点击按钮获得下标
    NSLog(@"======%ld", tabBarController.selectedIndex);
    NSLog(@"======%@", viewController);
}








- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
